# SimbodyConfig.cmake

# This should define the following:
#   Simbody_FOUND - Whether search for Simbody libraries and headers succeeded.
#   Simbody_ROOT_DIR - the installation directory; all the pieces must be
#                      found together
#   Simbody_INCLUDE_DIR - location of Simbody.h
#   Simbody_LIB_DIR     - location of libSimTKsimbody.{a,so,dylib}
#                         or SimTKsimbody.lib
#   Simbody_BIN_DIR     - location of .dll's on Windows
#   Simbody_VIZ_DIR     - location of simbody-visualizer
#   Simbody_LIBRARIES   - suitable for target_link_libraries(); includes
#                         both optimized and debug libraries if both are
#                         available
#   Simbody_STATIC_LIBRARIES - suitable for target_link_libraries(); includes
#                              both optimized and debug static libraries if
#                              both are available
#
# The following variables can be used in your own project so that your
# project's Doxygen documentation can link with Simbody's. These variables are
# only defined if Doxygen documentation is installed.
#   Simbody_DOXYGEN_DIR     - Directory containing Doxygen API documentation.
#   Simbody_DOXYGEN_TAGFILE - Path to SimbodyDoxygenTagFile.
#
# For example, if you're configuring your Doxyfile using CMake's
# configure_file, your Doxyfile.in file (to be configured) could contain
# (without the backslashes):
#
#   TAGFILES = "\@Simbody_DOXYGEN_TAGFILE\@=\@Simbody_DOXYGEN_DIR\@"

# To make the Simbody installation relocatable:
@PACKAGE_INIT@

# Watch out for spaces in pathnames -- must quote.
set_and_check(@PKG_NAME@_ROOT_DIR
              "@PACKAGE_CMAKE_INSTALL_PREFIX@")

set_and_check(@PKG_NAME@_INCLUDE_DIR
              "@PACKAGE_SIMBODY_INCLUDE_INSTALL_DIR@")

set_and_check(@PKG_NAME@_LIB_DIR
              "@PACKAGE_CMAKE_INSTALL_LIBDIR@")

list(APPEND @PKG_NAME@_BIN_DIR
            "@PACKAGE_CMAKE_INSTALL_BINDIR@")

list(APPEND @PKG_NAME@_VIZ_DIR
            "@PACKAGE_SIMBODY_VISUALIZER_INSTALL_DIR@")

list(APPEND @PKG_NAME@_CFLAGS
            -I"@PACKAGE_SIMBODY_INCLUDE_INSTALL_DIR@")

list(APPEND @PKG_NAME@_LDFLAGS
            -L"@PACKAGE_CMAKE_INSTALL_LIBDIR@")

if (NOT "@SIMBODY_DOXYGEN_TAGFILE_NAME@" STREQUAL "")
    # Must check tagfile variable, since the doxygen install dir is created
    # even if Doxygen documentation is not installed.
    set(temp_doxygen_dir "@PACKAGE_SIMBODY_INSTALL_DOXYGENDIR@")
    set(temp_tagfile_path
        "${temp_doxygen_dir}/@SIMBODY_DOXYGEN_TAGFILE_NAME@")
    if (EXISTS "${temp_tagfile_path}")
        set(@PKG_NAME@_DOXYGEN_DIR "${temp_doxygen_dir}")
        set(@PKG_NAME@_DOXYGEN_TAGFILE "${temp_tagfile_path}")
    endif()
    unset(temp_doxygen_dir)
    unset(temp_tagfile_path)
endif()

# Our library dependencies (contains definitions for IMPORTED targets)
include("${CMAKE_CURRENT_LIST_DIR}/SimbodyTargets.cmake")


# Create "fake" IMPORTED targets to represent the pre-built platform libraries
# that Simbody usually carries along on Windows.
# When CMake sees that a target links to, e.g., the blas target, CMake will
# use the appropriate library paths below.
set(SIMBODY_WAS_BUILT_USING_OTHER_LAPACK "@BUILD_USING_OTHER_LAPACK@")
if(WIN32 AND NOT SIMBODY_WAS_BUILT_USING_OTHER_LAPACK)
    add_library(blas SHARED IMPORTED)
    set_target_properties(blas PROPERTIES
        IMPORTED_IMPLIB "@PACKAGE_CMAKE_INSTALL_LIBDIR@/libblas.lib"
        IMPORTED_LOCATION "@PACKAGE_CMAKE_INSTALL_BINDIR@/libblas.dll"
        )

    add_library(lapack SHARED IMPORTED)
    set_target_properties(lapack PROPERTIES
        IMPORTED_IMPLIB "@PACKAGE_CMAKE_INSTALL_LIBDIR@/liblapack.lib"
        IMPORTED_LOCATION "@PACKAGE_CMAKE_INSTALL_BINDIR@/liblapack.dll"
        # lapack depends on blas:
        INTERFACE_LINK_LIBRARIES blas
        )
endif()


# These are IMPORTED targets created by SimbodyTargets.cmake
if(@BUILD_DYNAMIC_LIBRARIES@)
    set(Simbody_LIBRARIES @SimTKCOMMON_SHARED_LIBRARY@ @SimTKMATH_SHARED_LIBRARY@ @SimTKSIMBODY_SHARED_LIBRARY@)
else()
    set(Simbody_LIBRARIES Simbody_LIBRARIES-NOTFOUND)
endif()
if(@BUILD_STATIC_LIBRARIES@) # this is ON if static libraries were built
    set(Simbody_STATIC_LIBRARIES @SimTKCOMMON_STATIC_LIBRARY@ @SimTKMATH_STATIC_LIBRARY@ @SimTKSIMBODY_STATIC_LIBRARY@)
else()
    set(Simbody_STATIC_LIBRARIES Simbody_STATIC_LIBRARIES-NOTFOUND)
endif()
mark_as_advanced(Simbody_LIBRARIES Simbody_STATIC_LIBRARIES)

check_required_components(Simbody)
